﻿using RayDen.Library.Core;
using RayDen.Library.Core.Primitives;
using RayDen.Library.Entity.Interface;
using RayDen.RayEngine.Core.Types;

namespace RayDen.RayEngine.Core.Library
{
    public abstract class BaseCamera : ICamera
    {
        public Point Position { get; set; }
        public Vector Target { get; set; }
        public Vector Right { get; set; }
        public Vector Up { get; set; }
        public Vector Look { get; set; }
        public float Fov { get; set; }
        public float ZNear { get; set; }
        public float ZFar { get; set; }

        public abstract void GetRay(double x, double y, out RayData ray);
        public abstract void LookAt(Point vector, Point vector_2, Vector vector_3);

        public void GetRay(double x, double y, out IRay cameraRay)
        {
            RayData r;
            this.GetRay(x, y, out r);
            cameraRay = r;
        }
        public void Sample(float x, float y, float u0, float u1, float u2, out IRay ray, out float pdf)
        {
            pdf = 1f;
            GetRay(x, y, out ray);
        }
        public virtual void Sample(ref Point p, ref Normal N, ref Normal shadeN, float u0, float u1, float u2, out RayData eyeRay,
                                   out float pdf)
        {
            eyeRay = new RayData();
            pdf = 1f;
        }

        public abstract Point UnProject(ref Point v);
    }
}